jQuery(function($) {
	var $fzlc = $(".zlzy-fzlc");
	var $container = $fzlc.find(".zlzy-fzlc-container");
	var $fzlcitem = $container.find(".fzlc-item");
	var itemNum = $fzlcitem.size();
	//alert(itemNum);
	var $activePosition = $fzlc.find(".fzlc-active-position");
	var activeNum = 0;
	var _x = 0;
	var _y = 0;
	$fzlcitem.eq(activeNum).addClass("fzlc-item-active");
	$fzlcitem.find(".fzlc-item-date").each(function(i) {
		$(this).hover(function() {
			$fzlcitem.removeClass("fzlc-item-active");
			activeNum = i;
			$fzlcitem.eq(activeNum).addClass("fzlc-item-active");
			_x = $fzlcitem.eq(activeNum).position().left + 44;
			//alert(_x);
			$activePosition.animate({
				"left" : _x
			}, 100);
		}, function() {
		})
	})
	$(".fzlc-right-btn").click(function() {
		activeNum += 1;
		if (activeNum > 5) {
			//Debug;
			if (activeNum > (itemNum - 1)) {
				$(this).attr("title", "最后一条啦！")
				return;
			} else {
				$fzlcitem.removeClass("fzlc-item-active");
				$fzlcitem.eq(activeNum).addClass("fzlc-item-active");
				$container.animate({
					"margin-left" : "-" + (activeNum - 5) * 128 + "px"
				}, 100)
			}
		} else {
			$fzlcitem.removeClass("fzlc-item-active");
			$fzlcitem.eq(activeNum).addClass("fzlc-item-active");
			_x = $fzlcitem.eq(activeNum).position().left + 44;
			$activePosition.animate({
				"left" : _x
			}, 100);
		}
	})
	var _mleft = 0;
	$(".fzlc-left-btn").click(function() {
		activeNum -= 1;
		_mleft = parseFloat($container.css("margin-left").substr(0, 4));
		if (activeNum < 0) {
			return;
		}

		if (_mleft < 0) {
			_mleft += 128;
			$fzlcitem.removeClass("fzlc-item-active");
			$fzlcitem.eq(activeNum).addClass("fzlc-item-active");
			$container.animate({
				"margin-left" : _mleft + "px"
			}, 100);
		} else {
			_x = $fzlcitem.eq(activeNum).position().left + 44;
		}
		$fzlcitem.removeClass("fzlc-item-active");
		$fzlcitem.eq(activeNum).addClass("fzlc-item-active");
		$activePosition.animate({
			"left" : _x
		}, 100);
	})
})
